
package com.weiqiao.mall.repository;

import com.weiqiao.base.dao.IBaseMongoDao;
import com.weiqiao.mall.domain.MemberShipEntity;
import org.bson.Document;
import org.bson.conversions.Bson;

import java.util.List;

/**
 * 会员中心 持久化层 接口 继承IBaseMongoDao
 *
 * @author wangjian
 */
public interface IMemberShipRepository extends IBaseMongoDao {

    /**
     * 新建会员
     *
     * @param company_id
     * @param json
     * @return
     */
    boolean addMember(int company_id, String json);

    /**
     * 保存会员导出操作日志
     *
     * @param company_id
     * @param json
     * @return
     */
    boolean exportQueryMember(int company_id, String json);

    /**
     * 查询最大的会员Id
     */
    int findMaxMemberId(int company_id);

    /**
     * 根据条件查询会员(唯一)
     *
     * @param filter 查询条件
     * @return str
     */
    String queryMemberOneByFilter(int company_id, Bson filter);

    /**
     * 根据条件查询会员(集合)
     *
     * @param filter 查询条件
     * @return str
     */
    List<String> queryMemberListByFilter(int company_id, Bson filter);

    /**
     * 修改账户余额
     *
     * @param company_id   company_id
     * @param memberEntity memberEntity
     * @param account      account
     * @return bool
     */
    boolean updateBalance(int company_id, String phone, MemberShipEntity memberEntity, Double account);

    /**
     * 公司会员总积分
     * 主要为会员设置提供服务
     *
     * @param companyid 公司id
     * @param doc       查询条件
     * @return
     */
    MemberShipEntity getTotalMemberRewardPoints(int companyid, Document doc);

    /**
     * 会员激活
     *
     * @param company_id company_id
     * @param phone      phone
     * @return bool
     */
    boolean activationMember(int company_id, String phone, String unionId);

    /**
     * 修改会员
     *
     * @param company_id company_id
     * @return bool
     */
    boolean updateMember(int company_id, MemberShipEntity entity, int member_id);

    /**
     * 修改会员备注信息
     *
     * @param member_id
     * @param remarks
     * @return
     */
    boolean updateRemarks(int company_id, int member_id, String remarks);

    /**
     * 修改会员标签
     *
     * @param member_id member_id
     * @return bool
     */
    boolean updateLable(int company_id, int member_id, String fanLanbleList);

    /**
     * 删除会员标签
     *
     * @param member_id member_id
     * @return bool
     */
    boolean deleteLable(int company_id, int member_id, String fanLanble);

    /**
     * 根据条件查询会员数量
     *
     * @param company_id
     * @param bson
     * @return
     */
    int getMemebrNumByFilter(int company_id, Bson bson);

    /**
     * 分页查询会员列表
     *
     * @param company_id
     * @param bson
     * @param sort
     * @param skip
     * @param pageSize
     * @return
     */
    List<String> getMembersByFilterSortSkipLimt(int company_id, Bson bson, Bson sort, int skip, int pageSize);

    /**
     * 自增长
     *
     * @param companyid 公司id
     * @param filter    查询条件
     * @param doc       自增长数据
     * @return
     */
    boolean incEntity(int companyid, Bson filter, Document doc);

    /**
     * 排序查询会员列表
     *
     * @param company_id
     * @param filter
     * @param filterSort
     * @return
     */
    List<String> findLimit(int company_id, Bson filter, Bson filterSort);

    /**
     * 查找并更新
     *
     * @param companyId
     * @param bson
     * @param document
     * @param bool
     * @return
     */
    String findOneAndUpdate(int companyId, Bson bson, Document document, boolean bool);

    int statististics(int company_id, Bson bson);

    List<MemberShipEntity> findOrdersByFilterSortSkipLimt(int company_id, Bson bson, Bson sort, int skip, int pageSize);
}
